package com.moco.launcher.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.moco.launcher.R;
import com.moco.launcher.fragment.GuideFragment;
import com.moco.launcher.listener.IconPagerInterface;

public class GuideFragmentAdapter extends FragmentPagerAdapter implements
		IconPagerInterface {
	protected static final int[] ICONS = new int[] { R.drawable.guide1,
			R.drawable.guide2, R.drawable.guide3, R.drawable.guide4 };

	private int mCount = ICONS.length;

	public GuideFragmentAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public Fragment getItem(int position) {
		return GuideFragment.newInstance(ICONS[position % ICONS.length]);
	}

	@Override
	public int getCount() {
		return mCount;
	}

	@Override
	public int getIconResId(int index) {
		return ICONS[index % ICONS.length];
	}

	public void setCount(int count) {
		if (count > 0 && count <= 10) {
			mCount = count;
			notifyDataSetChanged();
		}
	}
}